/*
 * Copyright Aduna (http://www.aduna-software.com/) (c) 2008.
 *
 * Licensed under the Aduna BSD-style license.
 */
package edu.tju.commons.collections;

import java.io.Serializable;
import java.util.Comparator;

/**
 * Simple comparator that compares any two objects using their toString()
 * representation.
 * 
 * If a collated comparison is needed, use info.aduna.text.ToTextComparator
 * 
 * @author Herko ter Horst
 */
public class ToStringComparator implements Comparator<Object>, Serializable {

	private static final long serialVersionUID = 1822888208696272462L;

	public int compare(Object o1, Object o2) {
		int result = 0;

		if (o1 != o2) {
			result = o1.toString().compareTo(o2.toString());
		}

		return result;
	}
}
